<%@ page language="java" import="java.util.*" import="orm.*" pageEncoding="utf-8" errorPage="errorPage.jsp"%>
<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<%
	List paper = (List)session.getAttribute("paper");
 %>
 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">
<script language=javascript>
<!--
   	function activeElement(){
    	var forms = document.getElementById("testResult");
    	if(forms != null){
     		if(children(forms))
      			return true; 
    	}
     	return false;
   	}
   	//迭代判断焦点所在
   	function children(obj){
    	if(obj == document.activeElement) 
     		return false;
    	//如果有子元素
   		if(obj.hasChildNodes()){        
     		for(var i = 0; i < obj.childNodes.length; i++){
        		if(obj.childNodes[i] == document.activeElement && 
        			obj.childNodes[i].tagName.toLowerCase() != "td"){
        			if(obj.childNodes[i].type.toLowerCase() == "textarea"){
           				return true; 
        			}
       			}
             	if(children(obj.childNodes[i])) 
       				return true;
     		} 
     	}  
    	return false;
   	}
   	-->
</script>
<script language=javascript>
<!--
    function keydown(){
	   if(event.keyCode==8){
	   		if(activeElement()){
     			//alert("焦点是否在form里: true ");
      			event.returnValue=true;
     		}else{
		    	event.keyCode=0;
		    	event.returnValue=false;
		    	alert("当前考试不允许使用退格键");
		    }
	    }if(event.keyCode==116){
		    event.keyCode=0;
		    event.returnValue=false;
		    alert("当前考试不允许使用F5刷新键");
	    }if((event.altKey)&&((window.event.keyCode==37)||(window.event.keyCode==39))){
		   event.returnValue=false;
		   alert("当前考试不允许使用Alt+方向键←或方向键→");
	    }if((event.ctrlKey)&&(event.keyCode==78)){
	       event.returnValue=false;
	       alert("当前考试不允许使用Ctrl+n新建IE窗口");
	    }if((event.shiftKey)&&(event.keyCode==121)){
	       event.returnValue=false;
	       alert("当前考试不允许使用shift+F10");
	     }if(event.keyCode==27){
		    event.keyCode=0;
		    event.returnValue=false;
		    alert("当前考试不允许使用Esc键");
           }
      }
     function click() {
         event.returnValue=false;
	     alert("当前设置不允许使用右键！");
      }
     document.oncontextmenu=click;
     -->
  </script>
  </head>
  
  <body style="background-color: #efe8ef;" onkeydown="keydown()">
    <form action="startexam.do?action=submitexam" method="post" name="testResult" id="testResult">
    		<strong><font size="5">一.单选题</font></strong><br /><br />
           <%for(int i = 0; i < paper.size(); i++){
             	Map tempKnow = (Map)paper.get(i);
             	short subscore = ((Short)tempKnow.get("subscore")).shortValue();
             	List sub = (List)tempKnow.get("sub");
             	for (int j = 0; j < sub.size(); j++){
             		Question q = (Question)sub.get(j);
           %>
              <table width="100%" border="0" cellspacing="0" cellpadding="0">
	          <tr><td>
	               <font  size="4"><strong><%=String.valueOf(j + 1) %>.</strong>(<%=String.valueOf(subscore) %>分)
	                <%= q.getQtitle()%></font>
	               <br />
	               <%
	                  String[] option = q.getQoption().split("\\|\\&\\&\\|");
	                  for (int k = 0; k < option.length; k++){%>
	                   <input type="radio" name="<%= String.valueOf(q.getQid())%>" 
	                   value="<%=String.valueOf(k) %>" /> <%=option[k]%>
	                 <%}%><br /><br />
	          </td></tr> 
             </table>
             <% } }%><br />
             <strong><font size="5">二.多选题</font></strong><br /><br />
             <% for (int i = 0; i < paper.size(); i++){ 
             		Map tempKnow = (Map)paper.get(i);
             		short objmulscore = ((Short)tempKnow.get("objmulscore")).shortValue();
             		List objmul = (List)tempKnow.get("objmul");
             		for (int j = 0; j < objmul.size(); j++){
             			Question q = (Question)objmul.get(j);
             %>
             <table width="100%" border="0" cellspacing="0" cellpadding="0">
	          <tr><td>
	               <font size="4"><strong><%=String.valueOf(j + 1) %>.</strong>(<%=String.valueOf(objmulscore) %>分)
	                <%= q.getQtitle()%></font>
	               <br />
	               <%
	                  String[] option = q.getQoption().split("\\|\\&\\&\\|");
	                  for (int k = 0; k < option.length; k++){%>
	                   <input type="checkbox" name="<%= String.valueOf(q.getQid())%>" 
	                   value="<%=String.valueOf(k) %>" /> <%=option[k]%>
	                 <%}%><br /><br />
	          </td></tr> 
             </table>
             <% } }%><br />
             <strong><font size="5">三.主观题</font></strong><br /><br />
             <% for (int i = 0; i < paper.size(); i++){ 
             		Map tempKnow = (Map)paper.get(i);
             		short objscore = ((Short)tempKnow.get("objscore")).shortValue();
             		List obj = (List)tempKnow.get("obj");
             		for (int j = 0; j < obj.size(); j++){
             			Question q = (Question)obj.get(j);
             %>
             <table width="100%" border="0" cellspacing="0" cellpadding="0">
	          <tr><td>
	          	<font size="4"><strong><%=String.valueOf(j + 1) %>.</strong>(<%=String.valueOf(objscore) %>分)
	             <%= q.getQtitle()%></font>
	             <br />
	               <textarea rows="5" cols="100" name="<%=String.valueOf(q.getQid())%>" 
	               style="resize: none;" ></textarea>
	              <br /><br />
	          </td></tr> 
             </table>
             <%}}%>
       </form>
  </body>
</html>
